package com.fan.configService.controller;

import com.fan.configService.po.ResourceItem;
import com.fan.configService.service.ResourceItemService;
import com.fan.configService.vo.MyPage;
import com.fan.configService.vo.ResourceItemVo;
import com.fan.configService.vo.ResponseResult;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * java类简单作用描述
 *
 * @Description: java类作用描述
 * @Author: hf
 * @CreateDate: 2018/9/5 15:59
 * @UpdateUser: hf
 * @UpdateDate: 2018/9/5 15:59
 * @UpdateRemark: The modified content
 * @Version: 1.0
 */
@RestController
@RequestMapping("/resource")
public class ResourceItemController {
    @Autowired
    ResourceItemService resourceItemService;

    @GetMapping("/getItem/{resourceItemId}")
    public ResponseResult getResourceItem(@PathVariable Long resourceItemId) {
        ResponseResult responseResult = new ResponseResult();
        ResourceItem resourceItem = resourceItemService.getResourceItem(resourceItemId);
        ResourceItemVo resourceItemVo = new ResourceItemVo();
        BeanUtils.copyProperties(resourceItem, resourceItemVo);
        responseResult.setData(resourceItemVo);
        return responseResult;
    }


    @DeleteMapping("/delItem/{resourceItemId}")
    public ResponseResult delResourceItem(@PathVariable Long resourceItemId) {
        ResponseResult responseResult = new ResponseResult();
        resourceItemService.delResourceItem(resourceItemId);
        return responseResult;
    }


//    @PutMapping("/putItem/{resourceItemId}")
//    public ResponseResult updateResourceItem(@PathVariable Long resourceItemId, ResourceItemRequest resourceItemRequest) {
//        ResponseResult responseResult = new ResponseResult();
//        ResourceItem resourceItem = new ResourceItem();
//        BeanUtils.copyProperties(resourceItemRequest, resourceItem);
//        resourceItemService.updateResourceItem(resourceItem);
//        return responseResult;
//    }
//
//
//    @PutMapping("/putItem/{resourceItemId}")
//    public ResponseResult updateResourceItem(@PathVariable Long resourceItemId, ResourceItemRequest resourceItemRequest) {
//        ResponseResult responseResult = new ResponseResult();
//        ResourceItem resourceItem = new ResourceItem();
//        BeanUtils.copyProperties(resourceItemRequest, resourceItem);
//        resourceItemService.updateResourceItem(resourceItem);
//        return responseResult;
//    }


    @DeleteMapping("/test")
    public ResponseResult test(MyPage myPage) {
        ResponseResult responseResult = new ResponseResult();
        return  responseResult;
    }




}
